{% extends "default.html" %}

{% block content %}
<div class="title">
	Administraci&oacute;n Vinilos
</div>
<div class="content">
	<div>Registre los tipos de vinilos que la empresa tiene a la venta</div>
	<table id="itemtemplate_table">
		<tr>
			<th>C&oacute;digo</th>
			<th>Tama&ntilde;o</th>
			<th>Cantidad</th>
			<th>Precio</th>
			<th>Nombre</th>
			{% if request.vendor.is_owner %}
				<th>Acci&oacute;n</th>
			{% endif %}
		</tr>
		{% if request.vinyls %}
			{% for v in request.vinyls %}
			<tr>
				<td><a href="/vinyl/{{ v.id }}/">{{ v.code }}</a></th>
				<td>{{ v.size }}</td>
				<td>{{ v.quantity|floatformat:3 }}</td>
				<td>{{ v.price|floatformat:2 }}</td>
				<td>{{ v.name }}</td>
				{% if request.vendor.is_owner %}
					<td><a href="/vinyl/delete/{{ v.id }}">Eliminar</a></th>
				{% endif %}
			</tr>
			{% endfor %}
			<tr>
				<th colspan="6">TOTALES</th>
			</tr>
			<tr>
				<th colspan="2">Cantidad total en vinilos en metros</th>
				<td colspan="4">{{ request.vinyls_quantity|floatformat:2 }} m</td>
			</tr>
			<tr>
				<th colspan="2">Cantidad de vinilos en Kilogramos</th>
				<td colspan="4">{{ request.vinyls_quantity_kg|floatformat:2 }} Kg</td>
			</tr>
			<tr>
				<th colspan="2">Total dinero en vinilos</th>
				<td colspan="4">{{ request.vinyls_expended|floatformat:2 }} Bs</td>
			</tr>
		{% else %}
			<tr>
				<td colspan="2">
					No hay tipos de vinilos registrados
				</td>
			</tr>
		{% endif %}
	</table>
	<div>Puede registrar nuevos tipos de vinilos, ingresando la siguiente informaci&oacute;n</div>
	<form action="/vinyl/register/" method="post">
		<table id="itemtemplate_table_register">
			<tr>
				<th>C&oacute;digo</th>
				<td><input type="text" autocomplete="off" name="vinyl_code"></td>
			</tr>
			<tr>
				<th>Nombre</th>
				<td><input type="text"  autocomplete="off" name="vinyl_name"></td>
			</tr>
			<tr>
				<th>Tama&ntilde;o</th>
				<td><input type="text" autocomplete="off" name="vinyl_size"></td>
			</tr>
			<tr>
				<th>Precio</th>
				<td><input type="text"  autocomplete="off" name="vinyl_price"></td>
			</tr>
			<tr>
				<th>Moneda a utilizar</th>
				<td>
					{% if request.currencies %}
						<select name="vinyl_currency">
						{% for c in request.currencies %}
						<option value="{{ c.id }}">{{ c.name }}</option>
						{% endfor %}
						</select>
					{% else %}
					No se ha configurado el estado monetario de la aplicaci&oacute;n<br>Para configurarla ingrese <a href="/currency/"	>aqu&iacute;</a>
					{% endif %}
				</td>
			</tr>
			<tr>
				<th>En almac&eacute;n</th>
				<td>
					{% if request.warehouses %}
						<select name="vinyl_warehouse">
						{% for wh in request.warehouses %}
							<option value="{{ wh.id }}">{{ wh.name }}</option>
						{% endfor %}
						</select>
					{% else %}
					No existen almacenes registrados<br>Para registrar uno ingrese <a href="/warehouse/">aqu&iacute;</a>
					{% endif %}
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<input type="submit" value="Registrar">
				</td>
			</tr>
		</table>
	</form>
</div>
{% endblock %}